package com.vitabuybuy.tv.ui

import android.os.Bundle
import androidx.core.os.bundleOf
import com.library.common.base.BaseActivity
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ActivityPaySuccessBinding
import com.vitabuybuy.tv.ui.cart.viewmodel.ConfirmOrderViewModel
import kotlinx.android.synthetic.main.activity_pay_success.btnCheckOrder
import kotlinx.android.synthetic.main.activity_universality_result.*

class UniversalityResultActivity :
    BaseActivity<ConfirmOrderViewModel, ActivityPaySuccessBinding>() {
    override val isUseBaseTitleBar: Boolean
        get() = true
    override val layoutId: Int
        get() = R.layout.activity_universality_result

    companion object {
        const val FROM_OPEN_STORE = 0X11
        const val FROM_APPLY_TALENT_SUCCESS = 0X12
        const val FROM_WITH_DRAW_SUCCESS = 0X13
        const val FROM_CONVERSION_SUCCESS = 0X14
        fun openActivity(mContext: BaseActivity<*, *>, fromType: Int) {
            mContext.startActivity(
                bundleOf(Pair("fromType", fromType)),
                UniversalityResultActivity::class.java
            )
        }
    }

    private var fromType : Int?= 0
    override fun onGetBundle(bundle: Bundle?) {
        super.onGetBundle(bundle)
        fromType = bundle?.getInt("fromType")
    }

    override fun initView(savedInstanceState: Bundle?) {
        when (fromType) {
            FROM_OPEN_STORE -> {
                setTitle(getString(R.string.auth_result))
                tvHint.text = getString(R.string.authing_wait)
            }
            FROM_APPLY_TALENT_SUCCESS->{
                setTitle(getString(R.string.auth_result))
                tvHint.text = getString(R.string.authing_wait)
            }
            FROM_WITH_DRAW_SUCCESS->{
                setTitle(getString(R.string.withdraw))
                tvHint.text = getString(R.string.with_draw_pls_wait_auth)
            }
            FROM_CONVERSION_SUCCESS->{
                setTitle(getString(R.string.exchange_currency))
                tvHint.text = getString(R.string.exchange_currency_success)
            }
        }
    }

    override fun eventHandling() {
        btnCheckOrder.setOnClickListener {
            finish()
        }
    }
}
